#coding=utf-8

import epics
import tornado
from controller.BaseHandler import BaseHandler
from controller import cagetBool

class Handler(BaseHandler):

    @tornado.web.asynchronous
    @tornado.gen.coroutine
    def get(self):
        self.tplAssigns['Shtr18_SHTRRSH_OFF'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr18:SHTRRSH_OFF:SW:bi')
        self.tplAssigns['Shtr18_SHTR_ALM'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr18:SHTR_ALM:SW:bi')

        self.tplAssigns['Shtr1_SHTRRSH_OFF'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr1:SHTRRSH_OFF:SW:bi')
        self.tplAssigns['Shtr1_SHTR_ALM'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr1:SHTR_ALM:SW:bi')

        self.tplAssigns['Shtr6_SHTRRSH_OFF'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr6:SHTRRSH_OFF:SW:bi')
        self.tplAssigns['Shtr6_SHTR_ALM'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr6:SHTR_ALM:SW:bi')

        self.tplAssigns['Shtr9_SHTRRSH_OFF'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr9:SHTRRSH_OFF:SW:bi')
        self.tplAssigns['Shtr9_SHTR_ALM'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr9:SHTR_ALM:SW:bi')

        self.tplAssigns['Shtr20_SHTRRSH_OFF'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr20:SHTRRSH_OFF:SW:bi')
        self.tplAssigns['Shtr20_SHTR_ALM'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr20:SHTR_ALM:SW:bi')
        self.tplAssigns['Shtr2_SHTRRSH_OFF'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr2:SHTRRSH_OFF:SW:bi')
        self.tplAssigns['_2ndShutter_OFF'] = yield self.backend.submit(epics.caget, 'EXP_IB2_RM:2ndShutter:OFF')
        self.tplAssigns['Shtr2_SHTR_ALM'] = yield self.backend.submit(epics.caget, 'EXP_TB_SH:Shtr2:SHTR_ALM:SW:bi')
        self.render("ezca/shield.html", **self.tplAssigns)
        # tmps = [('EXP_TB_SH:Shtr18:SHTRRSH_OFF:SW:bi', 'Shtr18_SHTRRSH_OFF', ''), 
        # ('EXP_TB_SH:Shtr18:SHTR_ALM:SW:bi', 'Shtr18_SHTR_ALM', ''), 
        # ('EXP_TB_SH:Shtr1:SHTRRSH_OFF:SW:bi', 'Shtr1_SHTRRSH_OFF', ''), 
        # ('EXP_TB_SH:Shtr1:SHTR_ALM:SW:bi', 'Shtr1_SHTR_ALM', ''), 
        # ('EXP_TB_SH:Shtr6:SHTRRSH_OFF:SW:bi', 'Shtr6_SHTRRSH_OFF', ''), 
        # ('EXP_TB_SH:Shtr6:SHTR_ALM:SW:bi', 'Shtr6_SHTR_ALM', ''), 
        # ('EXP_TB_SH:Shtr9:SHTRRSH_OFF:SW:bi', 'Shtr9_SHTRRSH_OFF', ''), 
        # ('EXP_TB_SH:Shtr9:SHTR_ALM:SW:bi', 'Shtr9_SHTR_ALM', ''), 
        # ('EXP_TB_SH:Shtr20:SHTRRSH_OFF:SW:bi', 'Shtr20_SHTRRSH_OFF', ''), 
        # ('EXP_TB_SH:Shtr20:SHTR_ALM:SW:bi', 'Shtr20_SHTR_ALM', ''), 
        # ('EXP_TB_SH:Shtr2:SHTRRSH_OFF:SW:bi', 'Shtr2_SHTRRSH_OFF', ''), 
        # ('EXP_IB2_RM:2ndShutter:OFF', '_2ndShutter_OFF', ''), 
        # ('EXP_TB_SH:Shtr2:SHTR_ALM:SW:bi', 'Shtr2_SHTR_ALM', '')]
        # # vuls = yield [tornado.gen.Task(cagetBool, item) for item in tmps]
        # vuls = yield [self.backend.submit(cagetBool, item) for item in tmps]
        # for item in vuls: self.tplAssigns[item[0]] = item[1]

        # self.render("ezca/shield.html", **self.tplAssigns)
        # 返回内容
